#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_btn_finish_clicked()
{
    QString str = "我的性别是";
    if(ui->rb_man->isChecked()){
        str += "男生";
    }else if(ui->rb_woman->isChecked()){
        str += "女生";
    }else{
        str += "不便透露。";
    }

    str += "平时喜欢：";

    if(ui->cb_gym->isChecked()){
        str += ui->cb_gym->text();
        str += ",";
    }
    if(ui->cb_climb->isChecked()){
        str += ui->cb_climb->text();
        str += ",";
    }
    if(ui->cb_swim->isChecked()){
        str += ui->cb_swim->text();
        str += ",";
    }
    if(ui->cb_sing->isChecked()){
        str += ui->cb_sing->text();
        str += ",";
    }
    int pos = str.lastIndexOf(",");
    str.replace(pos, 1, ".");
    ui->text->setText(str);
}


void Widget::on_btn_clear_clicked()
{
    ui->rb_man->setAutoExclusive(false);
    ui->rb_man->setChecked(false);
    ui->rb_man->setAutoExclusive(true);

    ui->rb_woman->setAutoExclusive(false);
    ui->rb_woman->setChecked(false);
    ui->rb_woman->setAutoExclusive(true);

    ui->cb_gym->setChecked(false);
    ui->cb_climb->setChecked(false);
    ui->cb_swim->setChecked(false);
    ui->cb_sing->setChecked(false);

    ui->text->clear();
}

